/**
 * @project readnote
 * @Title BookServiceImpl.java
 * @author huxh
 * @date 2012-2-12
 **/
package com.readnote.user.service.impl;

import com.cr.backbone.hibenate.AppBaseServiceImpl;
import com.cr.backbone.util.UtilsTranscoding;
import com.readnote.user.dao.UserInfoDAO;
import com.readnote.user.model.User;
import com.readnote.user.model.UserInfo;
import com.readnote.user.service.UserInfoService;

public class UserInfoServiceImpl extends AppBaseServiceImpl<UserInfo> implements
		UserInfoService {

	public UserInfoDAO getDAO() {
		return ((UserInfoDAO) (dao));
	}

	public UserInfo getUserInfoByUser(User user) {
		if (user == null || user.isNullRow())
			return null;
		Long userId=user.getId();
		return getDAO().getUserInfoByUserId(userId);
	}

	public UserInfo saveUserInfoIfNotExitFromUser(User user) {
		if (user == null || user.isNullRow())
			return null;
		
		UserInfo ui =getUserInfoByUser(user);
		if(ui ==null || ui.isNullRow()){
			ui =new UserInfo();
			ui.setUser(user);
			getDAO().save(ui);
		}
		return ui;
	}

}
